import java.util.Stack;

public class Jisuanqi {
    public Double getResults(String texts) {
        Stack<Double> stk1=new Stack<Double>();
        Stack<Character> stk2=new Stack<Character>();
        for (int i=0; i < texts.length(); i++) {
            char temp=texts.charAt(i);
            if ((temp >= '0' && temp <= '9')) {
                double sum=temp - '0';
                int j=i + 1;
                boolean flag=true;
                int index=1;
                while (j < texts.length()) {
                    temp=texts.charAt(j);
                    if (flag && (temp >= '0' && temp <= '9')) {
                        sum=sum * 10 + temp - '0';
                        j++;
                    } else if (!flag && (temp >= '0' && temp <= '9')) {
                        sum+=Math.pow(0.1, index) * (temp - '0');
                        index++;
                        j++;
                    } else break;

                }
                stk1.push(new Double(sum));
                i=j - 1;
            } else if (temp == '+' || temp == '-' || temp == '*' || temp == '/' || temp == '(') {
                if (stk2.empty() || get_out_priority(temp) >= get_in_priority(stk2.peek().charValue()))
                    stk2.push(new Character(temp));
                else {
                    while (!stk2.empty() && (get_out_priority(temp) < get_in_priority(stk2.peek().charValue()))) {
                        char c=stk2.peek().charValue();
                        stk2.pop();
                        double num2=stk1.peek().doubleValue();
                        stk1.pop();
                        double num1=stk1.peek().doubleValue();
                        stk1.pop();
                        if (c == '+') stk1.push(new Double(num1 + num2));
                        if (c == '-') stk1.push(new Double(num1 - num2));
                        if (c == '*') stk1.push(new Double(num1 * num2));
                        if (c == '/') stk1.push(new Double(num1 / num2));
                    }
                    stk2.push(new Character(temp));
                }
            }
        }
        if (!stk2.empty()) {
            while (!stk2.empty()) {
                char c=stk2.peek().charValue();
                stk2.pop();
                double num2=stk1.peek().doubleValue();
                stk1.pop();
                double num1=stk1.peek().doubleValue();
                stk1.pop();
                if (c == '+') stk1.push(new Double(num1 + num2));
                if (c == '-') stk1.push(new Double(num1 - num2));
                if (c == '*') stk1.push(new Double(num1 * num2));
                if (c == '/') stk1.push(new Double(num1 / num2));
            }
        }
        return stk1.peek().doubleValue();
    }

    int get_out_priority(char temp) {
        if (temp == '+') return 3;
        if (temp == '-') return 3;
        if (temp == '*') return 4;
        if (temp == '/') return 4;
        return 0;
    }

    int get_in_priority(char temp) {
        if (temp == '+') return 3;
        if (temp == '-') return 3;
        if (temp == '*') return 4;
        if (temp == '/') return 4;
        return 0;
    }

//    public static void main(String[] args) {
//        jisuanqi051 a=new jisuanqi051();
//
//        System.out.println(a.getResults("135*32+6*10"));
//
//    }

}







